﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.echonest.api.v4;

namespace RequestEchoNest
{
    public class MetadataModel
    {
        internal TrackAnalysis  _metadata;

        internal Track _track;

        internal MetadataModel(TrackAnalysis metadata, Track t)
        {
            _metadata = metadata;
            _track = t;
        }

        public string Artist
        {
            get { return _track.getArtistName(); }
        }

        public double Loudness
        {
            get { return Double.Parse(_metadata.getLoudness().ToString()); }
        }

        public double Duration
        {
            get { return Double.Parse(_metadata.getDuration().ToString()); }
        }

        
        public double Tempo
        {
            get { return Double.Parse(_metadata.getTempo().ToString()); }
        }

        public string Title
        {
            get { return _track.getTitle(); }
        }



        public override string ToString()
        {
            return _metadata.ToString() + _track.ToString();
        }

        public bool Equals(MetadataModel other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other._metadata, _metadata);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(MetadataModel)) return false;
            return Equals((MetadataModel)obj);
        }

        public override int GetHashCode()
        {
            return (_metadata != null ? _metadata.GetHashCode() : 0);
        }
    }
}
